package com.stars.common.base.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.Column;

import java.util.Date;

/**
 * @author csot.qhluodajie on 2019/3/12.
 */
@Data
public class BaseEntity extends BasePropertyEntity {
    private static final long serialVersionUID = -750670559540645989L;
    /**
     * 创建人
     */
    @Column(name = "CREATE_NAME")
    private String createName;
    /**
     * 创建人ID
     */
    @Column(name = "CREATE_ID")
    private String createId;
    /**
     * 创建时间
     */
    @Column(name = "CREATE_DATE")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createDate;
    /**
     * 最后修改时间
     */
    @Column(name = "LAST_UPDATE_DATE")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastUpdateDate;
    /**
     * 最后修改人id
     */
    @Column(name = "LAST_UPDATE_ID")
    private String lastUpdateId;
    /**
     * 最后修改人
     */
    @Column(name = "LAST_UPDATE_NAME")
    @ApiModelProperty(value = "最后修改人")
    private String lastUpdateName;

    public void setUpdateInfo(BaseEntity region){
        this.setLastUpdateId(region.getLastUpdateId());
        this.setLastUpdateName(region.getLastUpdateName());
        this.setLastUpdateDate(new Date());
        this.versionAutoAdd();
    }
}
